package at.ac.tuwien.ir.model;

import java.util.LinkedList;
import java.util.List;

public class TokenWord
{
	private String m_word;
	private List<Document> m_documents;
	private List<Integer> m_termFrequencies;
	
	
	public TokenWord(String _word, Document _document, Integer _termFrequencies)
	{
		m_word = _word;
		m_documents = new LinkedList<Document>();
		m_termFrequencies = new LinkedList<Integer>();
		
		m_documents.add(_document);
		m_termFrequencies.add(_termFrequencies);
	}
	
	public void addDocument(Document document, Integer termFrequency)
	{
		m_documents.add(document);
		m_termFrequencies.add(termFrequency);
	}
	
	public List<Document> getPostingsList()
	{
		return m_documents;
	}
	
	public List<Integer> getTermFrequencyList()
	{
		return m_termFrequencies;
	}
	
	public String get_word()
	{
		return m_word;
	}
	
	public double calculateTermWeight(int documentIndex, int documentCount)
	{
		return Math.log10(1 + m_termFrequencies.get(documentIndex)) * Math.log10(documentCount / m_documents.size());
	}
	
}
